//
//  ProfileEditNameViewModel.swift
//  KoiAccounting
//
//  Created by 纪洪文 on 13.04.25.
//

import Foundation
class ProfileEditNameViewModel : KoiAccountingBaseViewModel {
    
    @Published var state = ""
    
    @Published var isLoading = false
    
    func nicknameModify(nickname: String) {
        self.isLoading = true
        KoiAccountingNetApi.standard.nicknameModify(nickname: nickname) { result in
            switch result {
            case .success:
                self.isLoading = false
                KoiAccountingUserManager.standard.updateUser(nickname: nickname)
                self.state = "success"
            case .failure(let failure):
                self.isLoading = false
                self.state = failure.netErrorMsg()
                logger.error("nicknameModify fail \(failure)")
            }
        }
    }
}
